package com.scm.property;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.log4j.Logger;
import com.scm.utils.DataService;

public class PropertyConfig implements IPropertyConfig{
	
	private static Logger log = Logger.getLogger(PropertyConfig.class);
	private final static String CONFIG = "config.properties";
	public  String DIR =  null;
	public  String SEPARATOR =  File.separator;
	private FileProperties properties =  null;
	
	public PropertyConfig(){
		properties =  new FileProperties(CONFIG);
	    DIR  =  properties.getProperties("scm.dir.properties");
	}

	
	public String getStringUrlPdf() {
		String urlPdf  =  properties.getProperties("smc.url.pdf_quote");
		return urlPdf;
	}

	
	public String getStringUrlClass(String tipo, String campionato) {
		String urlClass  =  properties.getProperties("smc.url.pdf_class");
		urlClass = urlClass.replace("<CAMPIONATO>", campionato);
		urlClass = urlClass.replace("<TIPO>",tipo);
		return urlClass;
	}

	
	public String getStringFilePdf() {
		String doc  =  properties.getProperties("smc.directory.pdf_quote");
		String file =  properties.getProperties("smc.file.pdf_quote").replace("<DATA>", DataService.getDataFormatFile());
		return DIR+SEPARATOR+doc+SEPARATOR+file;
	}
	
	
	public String getStringFileEsport() {
		String estensione = ".txt";
		String doc  =  properties.getProperties("smc.directory.pdf_quote");
		String file =  properties.getProperties("smc.file.pdf_quote").replace("<DATA>", DataService.getDataFormatFile());
		return DIR+SEPARATOR+doc+SEPARATOR+file+estensione;
	}

	
	public String getStringFileXMLquote() {
		String doc  =  properties.getProperties("smc.xml.dir");
		String file =  properties.getProperties("smc.xml.quote");
		return DIR+SEPARATOR+doc+SEPARATOR+file;
	}

	
	public String getStringFileXMLclass() {
		String doc  =  properties.getProperties("smc.xml.dir");
		String file =  properties.getProperties("smc.xml.classifica");
		return DIR+SEPARATOR+doc+SEPARATOR+file;
	}

	
	public String getStringIngestionUrl(String page) {
		String urlIngestion  =  properties.getProperties("smc.ingestion.url");
		return urlIngestion+page;
	}

	
	public String getStringSecretKey() {
		String secret  =  properties.getProperties("smc.ingestion.secretKEY");
		return secret;
	}

	
	public String getStringTokenKey() {
		String token  =  properties.getProperties("smc.ingestion.tokenKEY");
		return token;
	}

	
	public String getStringFileSecret() {
		String doc  =  properties.getProperties("smc.ssh.dir");
		String file =  properties.getProperties("smc.ssh.secret.file");
		return DIR+SEPARATOR+doc+SEPARATOR+file;
	}

	
	public String getStringFileToken() {
		String doc  =  properties.getProperties("smc.ssh.dir");
		String file =  properties.getProperties("smc.ssh.token.file");
		return DIR+SEPARATOR+doc+SEPARATOR+file;
	}

	
	public List<String> getListaCmpIngestion() {
		
		String lista  =  properties.getProperties("smc.lista.quote.ingestion");
		List<String> listCampionati = new ArrayList<String>();
		if(lista != null){
			String[] array = lista.split(",");
			listCampionati =  new ArrayList<String>(Arrays.asList(array)); 
			log.info("List Campionati Size:"+listCampionati.size());
			return listCampionati;
		}
		listCampionati = new ArrayList<String>();
		return listCampionati;
	}

	
	public String getStringUrlLive() {
		String urlLive  =  properties.getProperties("smc.url.live.score");
		return urlLive;
	}

}
